package com.meihuayishu.backend.dto;

import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "用户登录请求（增强版）")
public class UserLoginRequestV2 {
    
    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    @Schema(description = "手机号", example = "13800138000")
    private String phone;
    
    @Schema(description = "密码（密码登录时必填）", example = "123456Aa")
    private String password;
    
    @Pattern(regexp = "^\\d{6}$", message = "验证码必须为6位数字")
    @Schema(description = "短信验证码（验证码登录时必填）", example = "123456")
    private String verificationCode;
    
    @NotBlank(message = "登录类型不能为空")
    @Schema(description = "登录类型", allowableValues = {"PASSWORD", "SMS_CODE"})
    private String loginType;
    
    @Valid
    @NotNull(message = "设备信息不能为空")
    @Schema(description = "设备信息")
    private DeviceInfo deviceInfo;
    
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "设备信息")
    public static class DeviceInfo {
        @NotBlank(message = "平台不能为空")
        @Schema(description = "平台", allowableValues = {"ANDROID", "IOS", "WEB"})
        private String platform;
        
        @NotBlank(message = "设备ID不能为空")
        @Schema(description = "设备ID", example = "device_123456")
        private String deviceId;
        
        @NotBlank(message = "应用版本不能为空")
        @Schema(description = "应用版本", example = "1.0.0")
        private String appVersion;
    }
}